﻿Imports DTO
Imports System.Data
Imports System.Data.OleDb
Public Class ChiTiet_PKBDAO
    Public Function INSERT(ByVal pkb As ChiTiet_PKBDTO) As Integer
        ' ket noi csdl
        Dim DTP As New DataProvider()
        Dim cnn As New OleDbConnection
        cnn = DTP.ConnectDB()
        cnn.Open()
        ''
        ' cau truy van
        ''
        Dim query As String
        query = " insert into CHITIET_PKB(MaPhieu,MaThuoc,MaDonVi,SoLuong,MaCachDung,MaBenh) values (@maphieu,@mathuoc,@madonvi,@soluong,@macachdung,@mabenh) "
        Dim cmd As New OleDbCommand(query, cnn)
        'truyen du lieu
        Dim para As OleDbParameter
        para = cmd.Parameters.Add("@maphieu", OleDbType.BigInt)
        para.Value = pkb.MaPhieu
        para = cmd.Parameters.Add("@mathuoc", OleDbType.BigInt)
        para.Value = pkb.MaThuoc
        para = cmd.Parameters.Add("@madonvi", OleDbType.BigInt)
        para.Value = pkb.MaDonVi
        para = cmd.Parameters.Add("@soluong", OleDbType.BigInt)
        para.Value = pkb.SoLuong
        para = cmd.Parameters.Add("@macachdung", OleDbType.BigInt)
        para.Value = pkb.MACACHDUNG
        para = cmd.Parameters.Add("@mabenh", OleDbType.BigInt)
        para.Value = pkb.MABENH
        ''
        'thuc thi truy van
        Dim i As Integer = cmd.ExecuteNonQuery()
        'dong ket noi 
        cnn.Close()
        If (i > 0) Then
            Return 1 'them thanh công
        Else
            Return 0 'them that bai
        End If
    End Function
End Class
